package servlet.user;

import dao.UserDao;
import dao.service.UserDaoImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author cloudJiang
 * @date 2021/11/8 18:31
 */
@WebServlet("/userIDCheck")
public class UserIDCheck extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userID = req.getParameter("userID");
        UserDao userDao = new UserDaoImp();
        PrintWriter out = resp.getWriter();

        if (userDao.getUser(userID) != null) {
            out.write("false");
        } else {
            out.write("true");
        }
        out.close();

    }
}
